import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import http from './http/http.js'

import * as Icons from '@element-plus/icons-vue'

// 引入加密插件
import md5 from 'js-md5'

// 引入时间格式化插件
import moment from 'moment'

import ElementPlusMessage from './assets/js/elementPlusMessage'
import ElementPlusMessageBox from './assets/js/elementPlusMessageBox'
import ElementPlusLoading from './assets/js/elementPlusLoading'
import ElementPlusNotify from './assets/js/elementPlusNotify'

import {getDict, getDictValueByKey} from './utils/dictUtils.js'

// 引入要注册得自定义公共组件
import publicComponent from './components/index'

// 引入阿里全局图标
import '@/assets/icon/iconfont.css'

const app = createApp(App)

// 注册全局图标
Object.keys(Icons).forEach((key) => {
  app.component(key, Icons[key])
})

app.config.globalProperties.$getDict = getDict  // 将获取字典方法设置全局方法
app.config.globalProperties.$getDictValueByKey = getDictValueByKey // 将获取字典名称方法设置全局方法
app.config.globalProperties.$md5 = md5
app.config.globalProperties.$date = moment
app.config.globalProperties.$compList = import.meta.glob('@/views/**/*.vue') // 配置全局加载动态路由所需的平台文件路径

app.use(ElementPlusMessage)
app.use(ElementPlusMessageBox)
app.use(ElementPlusLoading)
app.use(ElementPlusNotify)
app.use(publicComponent)

app.use(http).use(store).use(router).mount('#app')
